package mapper;

import BO.QuestionNumberBO;
import DO.JudgeQuestionDO;
import DTO.PageJudgeQuestionDTO;
import DTO.UpdateJudgeQuestionDTO;
import VO.ChooseQuestionVO;
import VO.JudgeQuestionVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface JudgeQuestionMapper {

    // 分页查询第一步 ，查询总数
    Integer getTotal(PageJudgeQuestionDTO pageJudgeQuestionDTO);

    // 分页查询第二步， 查询页面数据
    List<JudgeQuestionVO> page(PageJudgeQuestionDTO pageJudgeQuestionDTO);

    // 获取所有编号
    @Select("select question_number from judge_question")
    List<String> getquestionNumber();

    // 添加题目
    void addQuestion(JudgeQuestionDO judgeQuestionDO);

    // 根据id删除题目
    @Delete("delete from judge_question where id = #{id}")
    void deleteById(Integer id);

    // 根据题目id获取题目答案
    @Select("select answer from judge_question where id = #{id}")
    Integer getAnswerById(Integer id);

    // 修改题目
    void updateById(UpdateJudgeQuestionDTO updateJudgeQuestionDTO);

    // 获取所有编号和id
    @Select("select id,question_number from judge_question where chapter>= #{startRange} and chapter<= #{endRange} order by question_number")
    List<QuestionNumberBO> getQuestionNumberAndId(Integer startRange,Integer endRange);

    // 根据id获取所有数据
    @Select("select * from judge_question where id = #{id}")
    JudgeQuestionDO getById(Integer id);
}
